bBase = {}
bBase.Font = nil
bBase.Icons = {}

function bBase:Init()
	self.Font = "Default"
	self:GenerateIcons()
end

function bBase:GenerateIcons()
	local xOffset, yOffset = 16, 16 + 16
	for i, turret in pairs(TURRETS.AllTurrets) do
		if turret.Unlocked == 1 and not self.Icons[i] then
			local si = vgui.Create("cSpawnIcon", self)
			si:SetPos(xOffset, yOffset)
			si:SetSize(64,64)
			si:SetImage("gui/nonsense/icons/"..turret.Icon)
			si:SetVisible(true)
			   
			-- ex for mouse functions
			si.OnMouseDown = function() StartBuilding(turret) end
			si.OnMouseUp = function() print("Up") end
			si.OnHover = function() print("Hover") end
			si.OnHoverOut = function() print("HoverOut") end

			xOffset = xOffset + 16 + 64
			self.Icons[i] = si -- important, else we have to recreate the icons over and over
		end
	end    
end

function bBase:SetFont(font)
	self.Font = font
end

function bBase:GetFont()
	return self.Font
end


function bBase:Paint()
	local x = self:GetWide()
	local y = self:GetTall()
	surface.SetFont(self.Font)
	local _,yvalue = surface.GetTextSize("X")
	surface.SetDrawColor(0,0,0,235)
	surface.DrawRect(0,0,x,y)
	surface.SetDrawColor(255,255,255,250)
	surface.DrawLine(0,yvalue+5,x,yvalue+5)
	surface.DrawOutlinedRect(0,0,x,y)
	surface.SetTextColor(255,255,255,200)
	surface.SetTextPos(5,5)
	surface.DrawText("Building Menu")
	local xvalue,_ = surface.GetTextSize("Building Menu")
	xvalue = xvalue+15
	surface.SetTextPos(xvalue,5)
	return true
end
vgui.Register("bBase",bBase,"Panel")